using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;

namespace zevenseas.Community.Web.UI.WebControls
{
    public class SPBoundHTMLField : SPBoundField
    {
        protected override void ChildControlDataBinding(Control childControl, object dataItem,
                                                        MemberDescriptor dataFieldPropertyDescriptor)
        {
            PlaceHolder placeHolder = (PlaceHolder)childControl;
            string propertyValueAsHtml = GetPropertyValueAsHtml(dataItem, dataFieldPropertyDescriptor.Name);
            if (!string.IsNullOrEmpty(propertyValueAsHtml))
            {
                Label label = new Label();
                label.Text = SPHttpUtility.HtmlDecode(propertyValueAsHtml);
                placeHolder.Controls.Add(label);
            }
        }
        protected override Control GetChildControlInstance()
        {
            return new PlaceHolder();
        }
    }
}